<?php

class SimpleTestGroupTool extends wakTool {

	function Factory($kit,$cfg) {
		return new SimpleTestGroupTool($kit,$cfg);
	}
	
	/**
	 * runs group tests
	 * currently calls setUp()
	 * then load kits from $cfg[load_kits]
	 * then run all declared test classes
	 * then call tearDown()
	 */
	function runTests() {
		// loading kits
		$kits=isset($this->cfg['load_kits'])?$this->cfg['load_kits']:array();
		foreach ($kits as $kit_id) {
			Webappkit::loadKit($kit_id);
		}
		// preparing test environment
		$this->setUp();
		
		if ($this->cfg['classes'])
			$this->runClasses($this->cfg['classes']);
		
		else // running all existing test classes
			$this->runAllClasses();
		
		// cleaning environment after tests
		$this->tearDown();
	}
	
	function setUp() {
		
	}
	
	function tearDown() {
		
	}
	
	/**
	 * run test classes
	 */
	function runClasses($classes) {
		$group=new GroupTest($this->cfg['group']['desc']);
		foreach ($classes as $class) {
			// adding class to group test
			$group->addTestClass($class);
		}
		// running group test
		$group->run(new HtmlReporter());
	}
	
	function runAllClasses() {
		$label='Kit '.$this->kit.', Group '.$this->cfg['group']['label'];
		SimpleTestKit::runAllTestClasses($label);
	}
	
	var $cfg=array(
		'group'=>array(
			'label'=>'',
			'desc'=>'')
		,'load_kits'=>array());
}

?>